FROM php:8.4-fpm-alpine

RUN apk add --no-cache \
    autoconf \
    gcc \
    make \
    musl-dev \
    bash \
    curl \
    libpng-dev \
    libjpeg-turbo-dev \
    freetype-dev \
    libzip-dev \
    zip \
    unzip \
    git \
    oniguruma-dev \
    icu-dev \
    nodejs \
    npm \
    && rm -rf /var/cache/apk/*

RUN docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-configure intl \
    && docker-php-ext-install -j$(nproc) \
    gd \
    pdo_mysql \
    zip \
    exif \
    pcntl \
    bcmath \
    opcache \
    intl \
    mbstring

RUN pecl install redis && \
    docker-php-ext-enable redis

# 启用 PHP 8.4 性能优化特性
RUN echo "opcache.jit_buffer_size=100M" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini \
    && echo "opcache.jit=1235" >> /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini


# 安装 Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# 设置工作目录
WORKDIR /var/www/html

# 容器启动命令
CMD ["php-fpm", "-F", "-O"]
